<?php

class Ext_Application_Resource_Queue extends Zend_Application_Resource_ResourceAbstract 
{
	protected $_queues;
	
	public function init() 
	{
		$options = $this->getOptions ();
		
		$this->_queues = array ();
		foreach ( $options as $name => $opt ) {
			$type = $opt ['type'];
			unset ( $opt ['type'] );
			$this->_queues [$name] = new Zend_Queue ( $type, $opt );
		}
		return $this;
	}
	
	public function getQueues() 
	{
		return $this->_queues;
	}
	
	public function getQueue($name) 
	{
		if (! isset ( $this->_queues [$name] )) {
			throw new Exception ( "Unconfigured queue $name" );
		}
		return $this->_queues [$name];
	}

}
